package meituan.summer11;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author Fizz Pu
 * @Date 2021/4/29 下午4:19
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int[] scores = new int[n];
        for(int i = 0; i < n; i++){
            scores[i] = scanner.nextInt();
        }

        Arrays.sort(scores);


        if(x <= 0){
            System.out.println("0");
        }

        if(x > n){
            throw  new IllegalArgumentException();
        }

        int xScore = scores[n - x];

        int counter = 0;
        for(int i = n - 1; i >= 0; i--){
            if(scores[i] > 0 && scores[i] >= xScore){
                counter++;
            } else {
                break;
            }
        }

        System.out.println(counter);
    }
}
